﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using LastoRevival.Service.Contracts.Models;

namespace LastoRevival.Service.Implementations.Data.Sql.Converters
{
	public class ForumAccessConfigurationCreator
	{
		public ForumAccessConfiguration Create(IEnumerable<DataRow> groupForums)
		{
			var accessRules = new ForumAccessConfiguration();

			foreach (var row in groupForums)
			{
				var forumID = (int)row["forumid"];
				var accessType = (ForumAccessType)row["AccessType"];

				accessRules.Add(forumID, accessType);
			}

			return accessRules;
		}
	}

	public class UserProfileDetailsCreator
	{

		public UserProfileDetails Create(DataRow userRow)
		{
			var userID = (int)userRow["userid"];
			var username = string.Format("{0}", userRow["username"]);
			var groupID = (int)userRow["groupid"];
			var locked = (bool)userRow["locked"];
			var verified = (bool)userRow["verified"];

			var user = new UserProfileDetails
			{
				UserID = userID,
				Username = username,
				GroupID = groupID,
				Locked = locked,
				Verified = verified,
			};

			return user;
		}
		
		private List<ForumFunctions> GetFunctionAccess()
		{
			// future
			return new List<ForumFunctions>();
		}


	}
}
